package com.liwq.base.sync;

/**
 * @author : liwq
 * @version : 1.0
 * @date : 2023/1/29
 **/
public class Ticket {

    private int num = 30;


    public synchronized void sale() {
        if (num > 0) {
            num = num - 1;
            System.out.println(Thread.currentThread().getName() + "卖了一张，还剩下：" + num);

        }


    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }
}
